package com.electric.flinkcep.model;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;

/**
 * 告警结果模型
 * 用于表示CEP模式匹配后生成的告警信息
 */
public class Alert implements Serializable {
    
    @JsonProperty("alertId")
    private String alertId;
    
    @JsonProperty("patternName")
    private String patternName;
    
    @JsonProperty("alertType")
    private String alertType;
    
    @JsonProperty("severity")
    private String severity;
    
    @JsonProperty("description")
    private String description;
    
    @JsonProperty("timestamp")
    private long timestamp;
    
    @JsonProperty("userId")
    private String userId;
    
    @JsonProperty("matchedEvents")
    private List<Event> matchedEvents;
    
    @JsonProperty("metadata")
    private String metadata;
    
    // 默认构造函数
    public Alert() {
    }
    
    // 全参构造函数
    public Alert(String alertId, String patternName, String alertType, String severity, 
                String description, long timestamp, String userId, List<Event> matchedEvents, String metadata) {
        this.alertId = alertId;
        this.patternName = patternName;
        this.alertType = alertType;
        this.severity = severity;
        this.description = description;
        this.timestamp = timestamp;
        this.userId = userId;
        this.matchedEvents = matchedEvents;
        this.metadata = metadata;
    }
    
    // Getter和Setter方法
    public String getAlertId() {
        return alertId;
    }
    
    public void setAlertId(String alertId) {
        this.alertId = alertId;
    }
    
    public String getPatternName() {
        return patternName;
    }
    
    public void setPatternName(String patternName) {
        this.patternName = patternName;
    }
    
    public String getAlertType() {
        return alertType;
    }
    
    public void setAlertType(String alertType) {
        this.alertType = alertType;
    }
    
    public String getSeverity() {
        return severity;
    }
    
    public void setSeverity(String severity) {
        this.severity = severity;
    }
    
    public String getDescription() {
        return description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public long getTimestamp() {
        return timestamp;
    }
    
    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }
    
    public String getUserId() {
        return userId;
    }
    
    public void setUserId(String userId) {
        this.userId = userId;
    }
    
    public List<Event> getMatchedEvents() {
        return matchedEvents;
    }
    
    public void setMatchedEvents(List<Event> matchedEvents) {
        this.matchedEvents = matchedEvents;
    }
    
    public String getMetadata() {
        return metadata;
    }
    
    public void setMetadata(String metadata) {
        this.metadata = metadata;
    }
    
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Alert alert = (Alert) o;
        return timestamp == alert.timestamp &&
                Objects.equals(alertId, alert.alertId) &&
                Objects.equals(patternName, alert.patternName) &&
                Objects.equals(alertType, alert.alertType) &&
                Objects.equals(severity, alert.severity) &&
                Objects.equals(description, alert.description) &&
                Objects.equals(userId, alert.userId) &&
                Objects.equals(matchedEvents, alert.matchedEvents) &&
                Objects.equals(metadata, alert.metadata);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(alertId, patternName, alertType, severity, description, timestamp, userId, matchedEvents, metadata);
    }
    
    @Override
    public String toString() {
        return "Alert{" +
                "alertId='" + alertId + '\'' +
                ", patternName='" + patternName + '\'' +
                ", alertType='" + alertType + '\'' +
                ", severity='" + severity + '\'' +
                ", description='" + description + '\'' +
                ", timestamp=" + timestamp +
                ", userId='" + userId + '\'' +
                ", matchedEvents=" + matchedEvents +
                ", metadata='" + metadata + '\'' +
                '}';
    }
}